import { IBehavior } from "./Behavior";

export class SelectorNode {
  private children: Array<IBehavior> = [];

  constructor(...children: Array<IBehavior>) {

    this.children = children;
  }

  public addChild(child: IBehavior): void {
    this.children.push(child);
  }

  public execute(): void {
    for (const child of this.children) {

      if (child.condition()) {
        child.action();
      }

    }

  }
}